| Conditions | 2 |
| Paths | 3 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import {each} from './utils' |
||
| 23 | export default function aliasesMixinMaker(options) { |
||
| 24 | let isEnabled |
||
| 25 | 2 | if (typeof options === 'boolean') { |
|
| 26 | 3 | isEnabled = () => options |
|
| 27 | } else { |
||
| 28 | 1 | isEnabled = key => { |
|
| 29 | 3 | return key in options && options[key] |
|
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | 2 | const mixin = { |
|
| 34 | computed: {}, // Variables |
||
| 35 | methods: {} |
||
| 36 | } |
||
| 37 | |||
| 38 | 2 | each(variables, (getter, key) => { |
|
| 39 | 2 | if (isEnabled(key)) { |
|
| 40 | 1 | mixin.computed[`$${key}`] = getter |
|
| 41 | } |
||
| 42 | }) |
||
| 43 | |||
| 44 | 2 | each(methods, (caller, key) => { |
|
| 45 | 4 | if (isEnabled(key)) { |
|
| 46 | 3 | mixin.methods[`$${key}`] = caller |
|
| 47 | } |
||
| 48 | }) |
||
| 49 | |||
| 50 | 2 | return mixin |
|
| 51 | } |
||
| 52 |